home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1997 September
/
Macworld (1997-09).dmg
/
Serious Software
/
Cherwell Scientific Demos
/
pro Fit
/
pro Fit 5.0 demo (fpu).sea
/
pro Fit 5.0 demo (fpu)
/
Functions & Programs
/
•Gadgets
/
ChiSquared
next >
Wrap
Text File
|
1996-06-01
|
837b
|
43 lines
{
calculates the sum of the differences squared of two columns in the current data window
To use this program, hit cmd-L (or click the Add button) and choose
its name from the Misc menu.
}
program Chi_squared;
var i, count:integer;
num:extended;
y1c,y2c:integer;
norm:boolean;
procedure initialize;
begin
y1c:=2;y2c:=3;norm:=0;
end;
begin
input('$Cy1 Column',y1c,'$Cy2 Column',y2c,'$Xnormalized',norm);
if ColEmpty(y1c) or ColEmpty(y2c) then
begin
beep;
halt;
end;
num:=0;
for i:=1 to NrRows do
begin
if dataok(i,y1c) and dataok(i,y2c) then
begin
num:=num+sqr(data[i,y1c] - data[i,y2c]);
if norm then count:=count+1;
end;
end;
if norm then
begin
writeln('#points = ',count); writeln('Chi-squared divided by #points = ',num/count)
end
else writeln('Chi-squared = ',num)
end;